let Permission = {
  isReady: false,
  isSuper: false,
  permissions: ['host.console.list']
};

// 前端页面的权限判断(仅作为前端功能展示的控制，具体权限控制应在后端实现)
export function hasPermission(code: string) {
  const {isSuper, permissions} = Permission;
  if (!code || isSuper) return true;
  for (let item of code.split('|')) {
    if (isSubArray(permissions, item.split('&'))) {
      return true
    }
  }
  return false
}

// 数组包含关系判断
export function isSubArray(parentArr: string[], childArr: string[]) {
  for (let item of childArr) {
    if (!parentArr.includes(item.trim())) {
      return false
    }
  }
  return true
}
